package main

import "strings"

type loc struct {
	x, y int
}

// moves 表示移动顺序   RLUD 四种
func judgeCircle(moves string) bool {
	orgin := loc{0, 0}
	for i := 0; i < len(moves); i++ {
		if moves[i] == 'R' {
			orgin.y++
		} else if moves[i] == 'L' {
			orgin.y--
		} else if moves[i] == 'U' {
			orgin.x--
		} else if moves[i] == 'D' {
			orgin.x++
		}
	}
	return orgin.x == 0 && orgin.y == 0
}

// 另一种方法，判断RL  UD是否成对
func judgeCircle1(moves string) bool {
	return  strings.Count(moves,"U") ==strings.Count(moves,"D") && strings.Count(moves,"R")==strings.Count(moves,"L")
}